<template>
    <div class="container">
    <el-card>
        <el-form ref="ruleFormRef"
                :model="form"
                :rules="rules"
                label-width="80px"
                class="demo-ruleForm">
            <el-form-item label="用户名" prop="username">
                <el-input v-model="form.username"></el-input>
            </el-form-item>
            <el-form-item label="密码" prop="password">
                <el-input v-model="form.password"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button @click="submit" type="primary">提交</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</div>
</template>

<script setup >
const form = reactive({
    username:'',
    password:''
})
const ruleFormRef = ref()

const rules = reactive({
    username: [{ required: true, message: '请输入用户名', trigger: 'blur' }, { min: 3, max: 8, message: '输入内容最多8个最少3个', trigger: 'blur' }],
    password: [{ required: true, message: '请输入密码', trigger: 'blur' },{ min: 3, max: 8, message: '输入内容最多8个最少3个', trigger: 'blur' }]
})
const submit = ()=>{
    ruleFormRef.value.validate((flag)=>{
        if(flag){
            console.log(111111111);
        }
    })
}
</script>

<style scoped lang="scss">
.container{
    width: 100%;
    height: 100vh;
    display: flex;
    .el-card{
        margin: auto;
        width: 500px;
        height: 300px;
        display: flex;
        justify-content: center;
        align-items: center;
       
    }
}
</style>
